package com.myidis.controller;

import com.myidis.entity.DIResult;
import com.myidis.entity.FullDIResult;
import com.myidis.entity.IndexCombination;
import com.myidis.entity.IndexResultList;
import com.myidis.request.DICalculatorReq;
import com.myidis.request.SearchReq;
import com.myidis.servlet.DICalculateServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
@RequestMapping("/DICalculate")
public class DICalculateController {
    @Autowired
    private DICalculateServlet dICalculateServlet;

    //计算结果列表调用的接口
    @ResponseBody
    @RequestMapping("/list")
    public ArrayList<IndexResultList> list() {
        return dICalculateServlet.all();
    }

    //查看某一条具体计算结果的接口
    @ResponseBody
    @RequestMapping("/Data")
    public ArrayList<FullDIResult> data(@RequestBody IndexResultList sea) {
        return dICalculateServlet.getData(sea);
    }

    //查看某一条计算结果的信息的接口
    @ResponseBody
    @RequestMapping("/info")
    public FullDIResult info(@RequestBody int sea) {
        return dICalculateServlet.getInfo(sea);
    }


    //计算一条新结果的接口
    @ResponseBody
    @RequestMapping("/calculate")
    public ArrayList<DIResult> calculate(@RequestBody DICalculatorReq req) {
        return dICalculateServlet.calculate(req);
    }

    //删除某一结果的接口
    @ResponseBody
    @RequestMapping("/del")
    public int calculate(@RequestBody int del) {
        return dICalculateServlet.delect(del);
    }

}